//
//  LDGCD.m
//
//  Created by Dean on 16/7/29.
//  Copyright © 2016年 Dean. All rights reserved.
//

#import "TGGCD.h"

@implementation TGGCD
#pragma mark  执行同步任务
+ (void)executeSyncTask:(dispatch_block_t)task{
    NSParameterAssert(task);
    // 如果当前队列是主队列，要提示奔溃处理
    dispatch_sync(globalQueue, task);
}
#pragma mark  执行异步任务
+ (void)executeAsyncTask:(dispatch_block_t)task{
    NSParameterAssert(task);
    dispatch_async(globalQueue, task);
}
#pragma mark  主线程调用
/**主线程执行操作*/
+ (void)executeMainAsyncTask:(dispatch_block_t)task{
    NSParameterAssert(task);
    dispatch_async(dispatch_get_main_queue(), task);
}
/**主线程操作*/
+ (void)executeMainOpeation:(void (^)(void))block {
    [[NSOperationQueue mainQueue] addOperationWithBlock:block];
}
/**延迟执行任务*/
+ (void)executeAfterTime:(int)time task:(void (^)(void))block
 {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         block();
     });
 }
@end
